package com.qianyucc.blog.model.vo;

import cn.hutool.core.bean.*;
import com.qianyucc.blog.model.entity.*;
import com.qianyucc.blog.utils.*;
import lombok.*;

import static com.qianyucc.blog.global.Constants.DEFAULT_DATE_TIME_PATTERN;

/**
 * @author lijing
 * @date 2019-10-12 18:18
 * @description 封装向前端返回的一篇文章的详细信息
 */
@Data
public class ArticleVO {
    public static ArticleVO create(ArticleDO articleDO) {
        ArticleVO articleVO = new ArticleVO();
        BeanUtil.copyProperties(articleDO, articleVO);
        articleVO.setTags(articleDO.getTags().split(","));
        articleVO.setGmtCreate(Utils.formatDate(articleDO.getGmtCreate(), DEFAULT_DATE_TIME_PATTERN));
        articleVO.setGmtUpdate(Utils.formatDate(articleDO.getGmtUpdate(), DEFAULT_DATE_TIME_PATTERN));
        return articleVO;
    }

    private String id;
    private String author;
    private String title;
    private String content;
    private String[] tags;
    private Integer type;
    private String category;
    private String gmtCreate;
    private String gmtUpdate;
    private String tabloid;
    private Integer comments;
    private Integer views;
}
